from datetime import datetime
from pydantic import BaseModel
from typing import List, Optional, Any, Dict

class ChatRequest(BaseModel):
    session_id: Optional[str] = None
    question: str
    provider: str
    mcp_server: str
    selected_model: Optional[str] = None

class ChatResponse(BaseModel):
    session_id: str
    success: bool
    result: Optional[str] = None
    query: Dict
    messages: List[Any]
    used_model: str



class ChatErrorData(BaseModel):
    """Error information for JSON-RPC error responses."""

    code: int
    """The error type that occurred."""

    message: str
    """
    A short description of the error. The message SHOULD be limited to a concise single
    sentence.
    """

    data: Any | None = None

# 新增聊天记录项模型
class ChatHistoryItem(BaseModel):
    id: int
    question: str  # 用户问题
    answer: str    # 模型回答
    timestamp: datetime  # 记录时间